﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace DAL
{
    using DAL.Entities;

    public class DangKyTaiKhoanDAL : BaseDAL, UTL.IBaseDAL
    {
        public int Count()
        {
            throw new NotImplementedException();
        }

        public DataTable Select()
        {
            throw new NotImplementedException();
        }

        public DataTable Select(object obj)
        {
            throw new NotImplementedException();
        }

        public object GetByKey(object key)
        {
            throw new NotImplementedException();
        }

        public bool Delete(string id)
        {
            throw new NotImplementedException();
        }

        public bool Insert(object obj)
        {
            var o = (Tai_Khoan)obj;
            string sql = @"INSERT INTO taikhoan(taikhoan,matkhau,ma_nv) VALUES('{0}','{1}','{2}')";
            sql = string.Format(sql,o.taikhoan,o.matkhau,o.manv);
            return ExecuteNonQuery(sql) > 0 ? true : false;
        }

        public bool Update(object obj)
        {
            throw new NotImplementedException();
        }

        public DataTable Search(string name)
        {
            throw new NotImplementedException();
        }
        public Boolean kt_taikhoan(string id)
        {
            string sql = @" select * from taikhoan where taikhoan='{0}' ";
            sql = string.Format(sql, id);
            DataTable dt = ExecuteQuery(sql);
            return dt.Rows.Count > 0 ? true : false;
        }
        public Boolean kt_nhanvien(string id)
        {
            string sql = @" select * from nhanvien where ma_nv='{0}' ";
            sql = string.Format(sql, id);
            DataTable dt = ExecuteQuery(sql);
            return dt.Rows.Count > 0 ? true : false;
        }
    }
}
